package com.xinchuang.mapper.targetSystem.scene;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xinchuang.entity.targetSystem.scene.SceneSystemsList;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @ClassName SceneSystemsListMapper
 * @Description: TODO(写一段描述的话)
 * @Author zhangxuan
 * @Date 2024-05-14 15:11
 * @Verion V1.0
 */
public interface SceneSystemsListMapper extends BaseMapper<SceneSystemsList> {

    @Select(value = {
            "SELECT sl.id,sl.intention,sm.sys_id,sm.systems_name,sl.create_time FROM scene_systems_list sl JOIN systems_master sm ON sl.sys_id = sm.sys_id"
    })
    @Results(
            value = {
                    @Result(property = "id", column = "id"),
                    @Result(property = "intention", column = "intention"),
                    @Result(property = "sysId", column = "sys_id"),
                    @Result(property = "sysName", column = "systems_name"),
                    @Result(
                            property = "targetLists",
                            column = "id",
                            javaType = List.class,
                            many = @Many(select = "com.xinchuang.mapper.targetSystem.scene.SceneTargetListMapper.selectTargetList"
                            ))
            }
    )
    List<SceneSystemsList> selectSceneList();

    @Select(value = {
            "SELECT id,missile_name FROM t_missile"
    })
    @Results(value = {
            @Result(property = "value", column = "id"),
            @Result(property = "label", column = "missile_name")
    })
    List<Map<String, Object>> getMissileList();

    @Select(value = "SELECT missile_name FROM t_missile WHERE id = #{missileId}")
    String getMissileName(String missileId);

    @Select(value = {
            "SELECT id,warhead_name FROM t_warhead WHERE missile_id = #{missileId}"
    })
    @Results(value = {
            @Result(property = "value", column = "id"),
            @Result(property = "label", column = "warhead_name")
    })
    List<Map<String, Object>> getWeaponList(String missileId);

    @Select(value = "SELECT warhead_name FROM t_warhead WHERE id = #{payloadId}")
    String getWeaponName(String payloadId);

    @Select(value = "SELECT avoid_hitting_name,lon,lat FROM t_avoid_hitting WHERE data_status = 0")
    @Results(value = {
            @Result(property = "targetName", column = "avoid_hitting_name"),
            @Result(property = "lon", column = "lon"),
            @Result(property = "lat", column = "lat"),
    })
    List<Map<String, Object>> getHitTarget();

}
